/// @tags: EulerCiruit
#include <cstdio>
#include <iostream>

using namespace std;

namespace BlueQuantum {

int const N = 1e5 + 5, H = 2e2 + 5;

int e_cnt;
int heads[H * 2], deg[H * 2];
bool flag, vis[H * 2];

struct Edge {
  int v, nxt;
} e[N << 1];

inline void add(int u, int v) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt;
}

void dfs(int u) {
  vis[u] = true;
  if (deg[u]) flag = true;
  for (int i = heads[u], v; i; i = e[i].nxt) {
    if (vis[v = e[i].v] == false) dfs(v);
  }
}

inline int main() {
  int n, h;
  cin >> n >> h;
  for (int i = 1, a, b, c, d; i <= n; ++i) {
    cin >> a >> b >> c >> d;
    a = c ? c + h : a;
    b = d ? d : b + h;
    deg[a]++, deg[b]--;
    add(a, b), add(b, a);
  }
  for (int i = 1; i <= h; ++i)
    if (deg[i] < 0 || deg[i + h] > 0) return cout << "NO", 0;
  for (int i = 1, lim = h * 2; i <= lim; ++i)
    if (vis[i] == false && heads[i]) {
      flag = false, dfs(i);
      if (flag == false) return cout << "NO", 0;
    }
  cout << "YES";
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("AT2668 [AGC017E] Jigsaw.in", "r", stdin);
  freopen("AT2668 [AGC017E] Jigsaw.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
